package com.qf.pkg.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qf.core.dto.PageDto;
import com.qf.core.vo.PageResult;
import com.qf.core.vo.R;
import com.qf.pkg.entity.Package;
import com.qf.pkg.entity.PackageTenantPerms;
import com.qf.pkg.mapper.PackageTenantPermsMapper;
import com.qf.pkg.service.PackageTenantPermsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author zhu
 * @since 2023-10-27
 */
@Service
public class PackageTenantPermsServiceImpl extends ServiceImpl<PackageTenantPermsMapper, PackageTenantPerms> implements PackageTenantPermsService {

    @Override
    public R add(PackageTenantPerms packageTenantPerms) {
        if (packageTenantPerms ==null){
            return R.fail();
        }
        this.baseMapper.insert(packageTenantPerms);
        return R.ok();
    }

    @Override
    public PageResult<PackageTenantPerms> page(PageDto<PackageTenantPerms> pageDto) {
        IPage<PackageTenantPerms> page = new Page<>(pageDto.getNow(),pageDto.getSize());

        //分页条件
        QueryWrapper<PackageTenantPerms> queryWrapper = new QueryWrapper<>();

        IPage<PackageTenantPerms> pageInfo = this.baseMapper.selectPage(page, queryWrapper);

        PageResult pageResult = new PageResult();
        pageResult.setList(pageInfo.getRecords());
        pageResult.setPages(pageInfo.getPages());
        pageResult.setTotal(pageInfo.getTotal());

        return pageResult;
    }

}
